<?php

namespace yifang\initializer;

use yifang\provider\ModelProvider;
use yifang\provider\PaginatorProvider;
use yifang\App;

class RegisterService
{
    protected $services = [
        PaginatorProvider::class,
        ModelProvider::class,
    ];

    public function init(App $app)
    {
        $file = $app->getYifangPath() . 'services.php';
        $services = $this->services;
        if (is_file($file)) {
            $services = array_merge($services, include $file);
        }
        foreach ($services as $service) {
            if (class_exists($service)) {
                $app->register($service);
            }
        }
    }
}